<extend name="./public/frame.html"/>
<block name="content">
    <form class="layui-form" action="{:url('submits')}" method="post">
        <input type="hidden" name="increment_id" value="{$config['increment_id']}"/>
        <table class="layui-table">
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="海购商城订单" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" name="haigou_status_checkbox" data-type="" lay-skin="switch" lay-filter="switchCheckHaigou" class="check" lay-text="开启|关闭" value="{$config['haigou_status']}" <if condition="$config['haigou_status'] eq 1">checked</if>>
                                <input type="hidden" name="haigou_status" value="{$config['haigou_status']}">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣百分比（%）</td>
                            <td><input class="layui-input" name="haigou_deduction_percentage" type="text" value="{$config['haigou_deduction_percentage']}" lay-verify="required|number" placeholder="请输入抵扣比例，如20%" onkeyup="clearNoNum(this)"></td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣上限（￥）</td>
                            <td><input class="layui-input" name="haigou_deduction_upper_limit" type="text" value="{$config['haigou_deduction_upper_limit']}" lay-verify="required|number" placeholder="请输入最高抵扣金额，如10元" onkeyup="clearNoNum(this)"></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="海宝商城订单" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" name="haibao_status_checkbox" data-type="" lay-skin="switch" lay-filter="switchCheckHaibo" class="check" lay-text="开启|关闭" value="{$config['haibao_status']}" <if condition="$config['haibao_status'] eq 1">checked</if>>
                                <input type="hidden" name="haibao_status" value="{$config['haibao_status']}">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣百分比（%）</td>
                            <td><input class="layui-input" name="haibao_deduction_percentage" type="text" value="{$config['haibao_deduction_percentage']}" lay-verify="number" placeholder="请输入抵扣比例，如20%" onkeyup="clearNoNum(this)"></td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣上限（￥）</td>
                            <td><input class="layui-input" name="haibao_deduction_upper_limit" type="text" value="{$config['haibao_deduction_upper_limit']}" lay-verify="required|number" placeholder="请输入最高抵扣金额，如10元" onkeyup="clearNoNum(this)"></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="快车订单" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" name="inner_status_checkbox" data-type="" lay-skin="switch" lay-filter="switchCheckInner" class="check" lay-text="开启|关闭" value="{$config['inner_status']}" <if condition="$config['inner_status'] eq 1">checked</if>>
                                <input type="hidden" name="inner_status" value="{$config['inner_status']}">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣百分比（%）</td>
                            <td><input class="layui-input" name="inner_deduction_percentage" type="text" value="{$config['inner_deduction_percentage']}" lay-verify="number" placeholder="请输入抵扣比例，如20%" onkeyup="clearNoNum(this)"></td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣上限（￥）</td>
                            <td><input class="layui-input" name="inner_deduction_upper_limit" type="text" value="{$config['inner_deduction_upper_limit']}" lay-verify="required|number" placeholder="请输入最高抵扣金额，如10元" onkeyup="clearNoNum(this)"></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="城际拼车订单" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" name="inter_status_checkbox" data-type="" lay-skin="switch" lay-filter="switchCheckInter" class="check" lay-text="开启|关闭" value="{$config['inter_status']}" <if condition="$config['inter_status'] eq 1">checked</if>>
                                <input type="hidden" name="inter_status" value="{$config['inter_status']}">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣百分比（%）</td>
                            <td><input class="layui-input" name="inter_deduction_percentage" type="text" value="{$config['inter_deduction_percentage']}" lay-verify="number" placeholder="请输入抵扣比例，如20%" onkeyup="clearNoNum(this)"></td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣上限（￥）</td>
                            <td><input class="layui-input" name="inter_deduction_upper_limit" type="text" value="{$config['inter_deduction_upper_limit']}" lay-verify="required|number" placeholder="请输入最高抵扣金额，如10元" onkeyup="clearNoNum(this)"></td>
                        </tr>
                    </table>
                </td>
            </tr>
            <tr>
                <td colspan="2">
                    <table class="layui-table">
                        <tr>
                            <td style="font-weight: bold;color: black; background:#F8F8F8" colspan="2">
                                <input type="text" class="layui-input" readonly value="顺风车订单" style="border: 0px;width: 30%;float: left;background:#F8F8F8">
                                <input type="checkbox" name="fr_status_checkbox" data-type="" lay-skin="switch" lay-filter="switchCheckFr" class="check" lay-text="开启|关闭" value="{$config['fr_status']}" <if condition="$config['fr_status'] eq 1">checked</if>>
                                <input type="hidden" name="fr_status" value="{$config['fr_status']}">
                            </td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣百分比（%）</td>
                            <td><input class="layui-input" name="fr_deduction_percentage" type="text" value="{$config['fr_deduction_percentage']}" lay-verify="number" placeholder="请输入抵扣比例，如20%" onkeyup="clearNoNum(this)"></td>
                        </tr>
                        <tr>
                            <td style="width: 12%;text-align: center;">抵扣上限（￥）</td>
                            <td><input class="layui-input" name="fr_deduction_upper_limit" type="text" value="{$config['fr_deduction_upper_limit']}" lay-verify="required|number" placeholder="请输入最高抵扣金额，如10元" onkeyup="clearNoNum(this)"></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        <button class="layui-btn" lay-submit="submit" lay-filter="submit">提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </form>
    <script>
        layui.use(['form', 'upload'], function(){
            var form = layui.form
                ,layer = layui.layer;
            form.on('switch(switchCheckHaigou)', function(data) {
                if (!this.checked) {
                    $("input[name='haigou_status_checkbox']").val(0);
                    $("input[name='haigou_status']").attr('value', 0);
                } else {
                    $("input[name='haigou_status_checkbox']").val(1);
                    $("input[name='haigou_status']").attr('value', 1);
                }
            });
            form.on('switch(switchCheckHaibo)', function(data){
                if(!this.checked){
                    $("input[name='haibao_status_checkbox']").val(0);
                    $("input[name='haibao_status']").attr('value', 0);
                }else{
                    $("input[name='haibao_status_checkbox']").val(1);
                    $("input[name='haibao_status']").attr('value', 1);
                }
            });
            form.on('switch(switchCheckInner)', function(data){
                if(!this.checked){
                    $("input[name='inner_status_checkbox']").val(0);
                    $("input[name='inner_status']").attr('value', 0);
                }else{
                    $("input[name='inner_status_checkbox']").val(1);
                    $("input[name='inner_status']").attr('value', 1);
                }
            });
            form.on('switch(switchCheckInter)', function(data){
                if(!this.checked){
                    $("input[name='inter_status_checkbox']").val(0);
                    $("input[name='inter_status']").attr('value', 0);
                }else{
                    $("input[name='inter_status_checkbox']").val(1);
                    $("input[name='inter_status']").attr('value', 1);
                }
            });
            form.on('switch(switchCheckFr)', function(data){
                if(!this.checked){
                    $("input[name='fr_status_checkbox']").val(0);
                    $("input[name='fr_status']").attr('value', 0);
                }else{
                    $("input[name='fr_status_checkbox']").val(1);
                    $("input[name='fr_status']").attr('value', 1);
                }
            });
        });

        //控制只能输入小数点后2位
        function clearNoNum(obj) {
            obj.value = obj.value.replace(/[^\d.]/g, "");  //清除“数字”和“.”以外的字符
            obj.value = obj.value.replace(/\.{2,}/g, "."); //只保留第一个. 清除多余的
            obj.value = obj.value.replace(".", "$#$").replace(/\./g, "").replace("$#$", ".");
            obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');//只能输入两个小数
            if (obj.value.indexOf(".") < 0 && obj.value != "") {    //以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
                obj.value = parseFloat(obj.value);
            }
        }
    </script>
</block>
